﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace DATN.mds.OpportunityManagement
{
    public partial class CreateOM : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string date_start = TextBox2.Text;
            DateTime da = DateTime.Parse(date_start);
            date_start = da.ToString("MM/dd/yyyy");

            string date_close = TextBox3.Text;
            DateTime da1 = DateTime.Parse(date_close);
            date_close = da1.ToString("MM/dd/yyyy");

            string date_create = TextBox4.Text;
            DateTime da2 = DateTime.Parse(date_create);
            date_create = da2.ToString("MM/dd/yyyy");

            string status = Drop_dow5.Text;
            string eti_fu = TextBox6.Text;
            string eti_pro = TextBox7.Text;
            
            

            SqlConnection cnn = new SqlConnection();
            cnn.ConnectionString = ConfigurationManager.ConnectionStrings["DATNconnection"].ToString();
            SqlCommand cmd = cnn.CreateCommand();


            string com1 = "Insert into Opportunities (Name, DateStart, DateClose, DateCreate, Status, EstimatesFund, EstimatesProfit, Us_Id)" +
                "" + "values(N'" + name + "','" + date_start + "','" + date_close + "','"
                + date_create + "',N'"
                + status + "','"
                + eti_fu + "','"
                + eti_pro + "','"+Convert.ToInt32(Session["Us_Id"].ToString())+"')";
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = com1;


            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();
            Page.Response.Redirect("~/mds.OpportunityManagement/IndexOM.aspx");


        }
    }
}